<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.solr.client.solrj.*"%>
<%@ page import="org.apache.solr.client.solrj.impl.*"%>
<%@ page import="org.apache.solr.client.solrj.response.QueryResponse"%>
<%@ page import="org.apache.solr.common.*"%>
<%@ page import="java.util.*"%>
<%@ page import="org.json.simple.*"%>

<%
	request.setCharacterEncoding("UTF-8");
	String search = request.getParameter("search");
	String cat = "cat :" + request.getParameter("search");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%@ include file="header.jsp"%>
</head>
<body id="page-top" class="index">
	<section id="search">
	<div class="container">
		<%@ include file="_menu.jsp"%>
		<div class="mainbody">
			<div class="row">
				<div class="col-lg-12">
					<form name="searchform" method="post" action="#">
						<div class="form-group input-group">
							<input type="text" class="form-control" name="research"
								id="reserch" placeholder="<%=search%>"> <span
								class="input-group-btn">
								<button type="button" class="btn btn-small">
									<i class="fa fa-search"></i>
								</button>
							</span>
						</div>
						<p class="help-block text-danger"></p>
						<br> <br>

						<%
							out.println(request.getParameter("search"));
						%>
					</form>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-8">
					<div class="app_var"></div>
					<div>
						<div>
							관련 검색 :
							<%
							try {
								String url = "http://192.168.0.16:8080/solr/test2";

								SolrServer server = new HttpSolrServer(url);
								SolrQuery query = new SolrQuery();

								query.setQuery("*:*");
								query.setRequestHandler("/select");
								query.setFields("name");

								SolrDocumentList results = new SolrDocumentList();
								JSONArray jArray = new JSONArray();
								QueryResponse rest_ = server.query(query);
								results = rest_.getResults();
								for (int i = 0; i < results.size(); ++i) {
									JSONObject json = new JSONObject(results.get(i));
									jArray.add(json);
									System.out.println(results.get(i));
								}
							} catch (Exception exc) {
								exc.printStackTrace();
							}
						%>
						</div>
						<hr />
						<div>도움말 :</div>
						<hr />
						<div></div>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="app_var"></div>
					<div>
						<div>관련 검색 :</div>
						<hr />
						<div>도움말 :</div>
						<hr />
						<div>
							<h1>본문입니다.</h1>

						</div>
					</div>
				</div>
			</div>

		</div>
	</div>
	<%@ include file="footer.jsp"%> </section>
</body>
</html>